<template>
  <div class="caseCenter">
    <div class="banner">
      <img src="../../../static/images/solutionBanner.jpg" class="img-res">
    </div>
    <div class="container">
      <h2 class="text-center">Global Case</h2>
      <div class="caseList">
        <el-row :gutter="20" class="listNav">
          <el-col :span="12" v-for="(item,index) in items" :key="index" class="navList">
              <router-link :to="{name:(item.name),params:{pageName:(item.description)}}">{{item.description}}</router-link>
          </el-col>
        </el-row>
      </div>
      <el-row :gutter="20" class="caseListA">
        <el-col :span="12" v-for="item in caseListA" :key="item.id">
          <router-link :to="'/case/' + (item.id)">
            <div class="grid-content proImg">
              <img :src="changeImgpath(item.litpic)" class="img-res">
            </div>
            <p>{{item.title}}</p>
          </router-link>
        </el-col>
      </el-row>
      <div class="page">
        <el-pagination
        background
        layout="prev, pager, next"
        @current-change="handleCurrentChange"
        :total="total">
        </el-pagination>
      </div>
    </div>

  </div>
</template>
<script>
import axios from 'axios'
export default {
  data () {
    return {
      items: [
        { name: 'AsiaCases', description: 'Asia' },
        { name: 'EuropeCases', description: 'Europe' },
        { name: 'AfricaCases', description: 'Africa' },
        { name: 'NorthAmericaCases', description: 'North America' },
        { name: 'LatinAmericaCases', description: 'Latin America' },
        { name: 'OceaniaCases', description: 'Oceania' }
      ],
      caseListA: {},
      total: null
    }
  },
  async mounted () {
    axios.get('/case/list/northamerica').then(response => {
      this.caseListA = response.data.data.data
      this.total = response.data.data.count
    }).catch(function (error) {
      console.log(error)
    })
  },
  methods: {
    handleClick (tab, event) {
      console.log(tab, event)
    },
    changeImgpath (img) {
      img = '//www.kefid.com' + img
      return img
    },
    handleCurrentChange (val) {
      axios.get('/case/list/northamerica?page=' + val).then(response => {
        this.caseListA = response.data.data.data
      }).catch(function (error) {
        console.log(error)
      })
    }
  }
}
</script>
<style scoped lang="css">
.caseCenter{
  padding-top: 52px;
}
.caseList .listNav .el-col-12{
  margin-bottom: 1rem;
}
.caseList .listNav .el-col-12 a{
  color: #333;
  padding: 0.8rem 0;
  display: block;
  background: #f7f7f7;
  text-align: center;
  font-size: 1.4rem;
  border-radius: 0.5rem;
  border: 1px solid #ccc;
}
.caseList .listNav .el-col-12 a.linkActive{
  color: #db3f28 !important;
}
.caseListA a{
  color: #333;
}
.caseListA .el-col-12{
  float: none;
  display: inline-block;
  vertical-align: top;
}
.caseListA .el-col-12 p{
  font-size: 1.2rem;
}
.page{
  text-align: center;
  margin: 1rem 0;
}
.img-res{
  width: 100%;
  height: auto;
}
.router-link-exact-active,.router-link-active{
  color: #fa4554 !important;
}
</style>
